vector<int> nextLargerNodes(ListNode* head) {
        vector<int> ans;
        ListNode *pre = head;
        while(pre)
        {
            ListNode *cur = pre->next;
            while(cur)
            {
                if(cur->val > pre->val)
                {
                    ans.push_back(cur->val);
                    break;
                }
                else
                    cur = cur->next;
            }
            if(!cur)
                ans.push_back(0);  
            pre = pre->next;  
        }
        return ans;
    }